﻿using DataStructure;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using DataStructure;

namespace DataStructure.Test
{


    /// <summary>
    ///This is a test class for LinearListTest and is intended
    ///to contain all LinearListTest Unit Tests
    ///</summary>
    [TestClass()]
    public class LinearListTest
    {


        private TestContext testContextInstance;

        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        #region Additional test attributes
        // 
        //You can use the following additional attributes as you write your tests:
        //
        //Use ClassInitialize to run code before running the first test in the class
        //[ClassInitialize()]
        //public static void MyClassInitialize(TestContext testContext)
        //{
        //}
        //
        //Use ClassCleanup to run code after all tests in a class have run
        //[ClassCleanup()]
        //public static void MyClassCleanup()
        //{
        //}
        //
        //Use TestInitialize to run code before running each test
        //[TestInitialize()]
        //public void MyTestInitialize()
        //{
        //}
        //
        //Use TestCleanup to run code after each test has run
        //[TestCleanup()]
        //public void MyTestCleanup()
        //{
        //}
        //
        #endregion


        /// <summary>
        ///A test for LinearList Constructor
        ///</summary>
        [TestMethod()]
        public void LinearListConstructorTest()
        {
            Nodes target = new Nodes(new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 });
            Assert.AreEqual<int>(10, target.GetLength());

            for (int i = 0; i < 10; i++)
            {
                Assert.AreEqual<int>(i + 1, target.GetNode(i + 1).Data);
            }

            target = new Nodes(new int[] { 1 });
            Assert.AreEqual<int>(1, target.GetLength());
        }

        /// <summary>
        ///A test for LinearList Constructor
        ///</summary>
        [TestMethod()]
        public void LinearListConstructorTest1()
        {
            var target = new Nodes(new int[] { });
            Assert.AreEqual<int>(0, target.GetLength());
        }

        /// <summary>
        ///A test for GetLength
        ///</summary>
        [TestMethod()]
        public void GetLengthTest()
        {
            int[] datas = null; // TODO: Initialize to an appropriate value
            Nodes target = new Nodes(datas); // TODO: Initialize to an appropriate value
            int expected = 0; // TODO: Initialize to an appropriate value
            int actual;
            actual = target.GetLength();
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("Verify the correctness of this test method.");
        }

        /// <summary>
        ///A test for GetNode
        ///</summary>
        [TestMethod()]
        public void ReverseTest()
        {
            int count = 20;
            int[] datas = new int[count];
            for (int i = 0; i < datas.Length; i++)
            {
                datas[i] = i + 1;
            }
            Nodes target = new Nodes(datas);
            Assert.AreEqual<int>(count, target.GetLength());

            target.Show();

            Nodes.Reverse(target, 4);
            target.Show();

            Nodes.Reverse(target, 4);
            target.Show();
        }
    }
}
